package com.bwie.topnews;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.bwie.fragment.Fragment0;
import com.bwie.view.ViewPagerIndicator;

public class MainActivity extends AppCompatActivity {

    private ViewPagerIndicator viewPagerIndicator;
    private ViewPager vp;
    String[] title=new String[]{"推荐","热点","视频","北京","社会","图片","头条号","娱乐","科技","汽车","体育","财经","军事"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
      /* Mybase base=new Mybase(){

            @Override
            public void setResultData(String data) {
                Toast.makeText(MainActivity.this, data+"---", Toast.LENGTH_SHORT).show();
            }

            @Override
            protected void setFailResult(int code) {
                Toast.makeText(MainActivity.this, "fail"+code, Toast.LENGTH_SHORT).show();
            }
        };
        base.getData("http://www.tencent.com",1000*60);*/
        viewPagerIndicator = (ViewPagerIndicator) findViewById(R.id.viewpagerIndicator);
        vp = (ViewPager) findViewById(R.id.viewPager);
        vp.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public Fragment getItem(int position) {
                return Fragment0.getFragment(title[position]);
            }

            @Override
            public int getCount() {
                return title.length;
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return title[position];
            }
        });
        viewPagerIndicator.setViewPager(vp);
    }

}
